<template>
	<view>
		<view
			style="display: flex;justify-content: left;align-items: center; border-bottom: 1px solid #ddd; font-weight: bold; font-size: 18px;">
			<image src="../../static/imager/Z_W.png" mode="aspectFit" style="width: 45px;height: 45px;"></image>
			<text @click="wx">微信支付</text>
		</view>
		<view
			style="mmargin-top: 10px;  display: flex;justify-content: left;align-items: center; border-bottom: 1px solid #ddd; font-weight: bold; font-size: 18px;">
			<image src="../../static/imager/Z_Z.png" mode="aspectFit" style="width: 45px;height: 45px;"></image>
			<text @click="zfb">支付宝支付</text>
		</view>
		<view
			style="mmargin-top: 10px;  display: flex;justify-content: left;align-items: center; border-bottom: 1px solid #ddd; font-weight: bold; font-size: 18px;">
			<image src="../../static/imager/780.jpg" mode="aspectFit" style="width: 45px;height: 45px;"></image>
			<text @click="yh">中国农业银行支付</text>
		</view>
		<uni-popup ref="popup" type="dialog">
			<uni-popup-dialog title="充值" @confirm="topUp">
				<text>你确定要{{type}}吗？</text>
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {},
				type: null,
				money:null,
				login:{}
			}
		},
		methods: {
			topUp(){
				uni.request({
					url: this.api.updateUserMoney,
					method: 'PUT',
					data: {
						userId:this.user.userId,
						type:this.type,
						userMoney:this.money
					},
					success: res => {
						if(res.data.code==200){
							this.login=res.data.obj
							this.login.userImage="http://127.0.0.1:8989/"+this.login.userImage
							uni.setStorageSync('token',this.login)
							uni.navigateBack({
								delta: 1
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			wx() {
				this.type = "微信充值"
				this.$refs.popup.open()
			},
			zfb() {
				this.type = "支付宝充值"
				this.$refs.popup.open()
			},
			yh() {
				this.type = "中国农业银行充值"
				this.$refs.popup.open()
			},
		},
		onLoad(open) {
			this.money=open.money
			if (uni.getStorageSync('token')) {
				this.user = uni.getStorageSync('token')
			}
		}
	}
</script>

<style>

</style>
